#include "constant.h"
#include "request.h"
#include "log.h"
#include "database.h"

int init_cli_db(struct request *req)
{
	
	
	req->mysql = mysql_init(0);
	if (!req->mysql)	{
		LOG_ERR("mysql_init faild: %s\n", mysql_error(req->mysql));	
		return BS_ERROR;
	}
	LOG_DEBUG("client init db success\n");
	
	if ( !mysql_real_connect(req->mysql ,MYSQL_HOST, MYSQL_USER , MYSQL_PSWD, MYSQL_BASE, 0, NULL, 0) ) {
		LOG_ERR("mysql_real_connect failed: %s\n", mysql_error(req->mysql) );	
		return BS_ERROR;
	}
	LOG_DEBUG("client connect db success\n");
	
	return BS_OK;
}